/**
 *  Location.java : IceBird project
 *  17:12:47 
 */
package icebird.compiler.ncomp.vs;


/**
 * Represents abstract location.
 * @author Sergey Shulepoff[Knott]
 */
public abstract class Location {

	private String name;
	
	protected Location(String name) {
		this.name = name;
	}
	
	/**
	 * Gets string representation.
	 */
	public String toString() {
		return name;
	}
	
	/**
	 * Gets cost to operate this item.
	 * @return int
	 */
	public abstract int getWeight();
	
	/**
	 * Is this location is constant?
	 * @return boolean
	 */
	public final boolean isConstant() {
		return (this instanceof ConstLocation);
	}
	
	/**
	 * Is this location is GP Register?
	 * @return boolean
	 */
	public final boolean isGPR() {
		return (this instanceof GPRLocation) ||
			   (this instanceof GPR2Location);
	}
	
	/**
	 * Is this location is SSE register?
	 * @return boolean
	 */
	public final boolean isSSE() {
		return (this instanceof SSELocation);
	}
	
	/**
	 * Is this location is FPU stack?
	 * @return boolean
	 */
	public final boolean isFPUStack() {
		return (this instanceof FPULocation);
	}
	
	/**
	 * Is this location is stack?
	 * @return boolean
	 */
	public final boolean isStack() {
		return (this instanceof StackLocation);
	}
	
	/**
	 * Is this location is local?
	 * @return boolean
	 */
	public final boolean isLocal() {
		return (this instanceof LocalLocation);
	}
}
